package com.accp.crm.service;


import java.util.List;

import org.hibernate.SessionFactory;

import com.accp.crm.dao.CommonDAO;
import com.accp.crm.entity.SysRight;

public class RightService implements IRightService {
	 private CommonDAO<SysRight> rightDAO;
	 public void setSessionFactory(SessionFactory sessionFactory){
		 rightDAO=new CommonDAO<SysRight>(sessionFactory, SysRight.class);
	 }
	@Override
	public void add(SysRight right) {
		String[] methods=right.getMethods();
		String methodStr="";
		for (int i = 0; i < methods.length; i++) {
			methodStr+=","+methods[i];
		}
		
		
		methodStr=methodStr.substring(1);
		right.setRightAction(methodStr);
		
		
		this.rightDAO.save(right);
	}
	@Override
	public List findByName(String name) {
		String hql="select rightVoid from SysRight where rightName=?";
		return this.rightDAO.findByHQL(hql, name);
	}
}
